"""
1. 数字随机产生，范围1-10
2. 有3次机会猜测数字，通过3层if嵌套判断实现
3. 每次猜不中，会提示大了或小了
"""
import random
num = random.randint(1,10)
your_num = int(input("请输入你猜测的数字，范围1-10："))

# 以不等为起始判断
if your_num != num:
    if your_num > num:
        print("大了")
        your_num = int(input("请再次猜测："))
        if your_num != num:
            if your_num > num:
                print("大了")
                your_num = int(input("最后一次猜测："))
                if your_num != num:
                    print("3次都没对，随机数是：%s" % num)
                else:
                    print("最后一次猜对了")
            elif your_num < num:
                print("小了")
                your_num = int(input("最后一次猜测："))
                if your_num != num:
                    print("3次都没对，随机数是：%s" % num)
                else:
                    print("最后一次猜对了")
        else:
            print("第二次猜对了")
    elif your_num < num:
        print("小了")
        your_num = int(input("请再次猜测："))
        if your_num != num:
            if your_num > num:
                print("大了")
                your_num = int(input("最后一次猜测："))
                if your_num != num:
                    print("3次都没对，随机数是：%s" % num)
                else:
                    print("最后一次猜对了")
            elif your_num < num:
                print("小了")
                your_num = int(input("最后一次猜测："))
                if your_num != num:
                   print("3次都没对，随机数是：%s" % num)
                else:
                    print("最后一次猜对了")
        else:
            print("第二次猜对了")
else:
    print("猜对了")

#  以相等为起始判断
# if your_num == num:
#     print("恭喜第一次就猜对了")
# else:
#     if your_num > num:
#         print("大了")
#     else:
#         print("小了")
#     your_num = int(input("请再次猜测："))
#     if your_num == num:
#         print("恭喜第二次猜对了")
#     else:
#         if your_num > num:
#             print("大了")
#         else:
#             print("小了")
#         your_num = int(input("最后一次猜测："))
#         if your_num == num:
#             print("最后一次猜对了")
#         else:
#             print("3次机会都没对，随机数是：%s" % num)
